package com.asiainfo.order.config;


import feign.Logger;
import feign.Retryer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;



@Configuration
public class OrderConfig {
    //该实例全局唯一，线程安全
    @LoadBalanced
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();

    }


    //开启openfeign日志
    @Bean
    public Logger.Level loggerL(){
        return Logger.Level.FULL;
    }

    //设置Openfign的重试机制，默认重试5次
//    默认重试5次，初始间隔100毫秒，后续每次乘1.5，最多间隔1秒
  /*  @Bean
    Retryer retry(){
        *//**
         *    public Default() {
         *             this(100L, TimeUnit.SECONDS.toMillis(1L), 5);
         *         }
         *//*
        return new Retryer.Default();
//        return new Retryer.Default(2000L,1,3);
    }*/
}

